import React from 'react';
import qs from 'qs';
const control = new AbortController();
const fetchHandler = ()=>{
    const response =  fetch('/api/list',{
        method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: qs.stringify({
            id:1,
            name:1
        }),
        signal: control.signal,
    });
    response.then(response => {
        const {headers,status,statusText}=response;
        if(/^([23])\d{2}$/.test(status)){
            console.log(status);
        }
        return Promise.reject(statusText);
    }).catch(error => console.log(error));
    control.abort();
}

export const FetchComp = function () {
    fetchHandler();
    return (
        <>

        </>
    )

};